let arr1: [string, number]
let arr2: [string, boolean?]
let arr3: [number, ...string[]]

arr1 = ['hello', 200]
arr2 = ['hello', false]
arr3 = [100, 'a', 'b', 'c']

console.log(arr1, arr2, arr3)


function walk(str: string) {
    if (str === 'up') {
        console.log('向[上]走')
    } else if (str === 'down') {
        console.log('向[下]走')
    } else if (str === 'left') {
        console.log('向[左]走')
    } else if (str === 'right') {
        console.log('向[右]走')
    } else {
        console.log('未知方向')
    }
}
walk('up')
walk('down')
walk('left')
walk('right')


// 枚举
enum Direction {
    Up,
    Down,
    Left,
    Right
}

console.log(Direction)

function walkEnum(data: Direction) {
    if (data === Direction.Up) {
        console.log('向[上]走')
    } else if (data === Direction.Down) {
        console.log('向[下]走')
    } else if (data === Direction.Left) {
        console.log('向[左]走')
    } else if (data === Direction.Right) {
        console.log('向[右]走')
    } else {
        console.log('未知方向')
    }
}

// walkEnum('up') //Argument of type '"up"' is not assignable to parameter of type 'Direction'
walkEnum(Direction.Up)

// 枚举
enum Direction1 {
    Up = 5,
    Down = 12,
    Left,
    Right
}

console.log(Direction1, '数字枚举')

// 字符串枚举
enum Direction2 {
    Up = '1',
    Down = '2',
    Left = '3',
    Right = '4'
}
console.log(Direction2, '字符串枚举')


const enum Direction3 {
    Up,
    Down,
    Left,
    Right
}
let x = Direction3.Up